<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>测试报告</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="shortcut icon" href="../resources/favicon.ico" th:href="@{/static/favicon.ico}"/>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<div style="display: flex;">
    <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 20px;margin-right: 20px" action="">
        <div class="layui-form-item" >

            <div class="layui-inline">
                <label class="layui-form-label">任务名称:</label>
                <div class="layui-input-inline">
                    <input type="text" name="taskId" id="taskId" autocomplete="off" placeholder="请输入任务名称" class="layui-input" >
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">业务名称:</label>
                <div class="layui-input-inline">
                    <input type="text" name="labelName" id="labelName" autocomplete="off" placeholder="请输入业务名称" class="layui-input" >
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">用例名称:</label>
                <div class="layui-input-inline">
                    <input type="text" name="tag" id="tag" autocomplete="off" placeholder="请输入用例名称" class="layui-input" >
                </div>
            </div>

        </div>

    </form>
    <div class="layui-inline" style="margin-top: 20px;float: right">
        <button type="button" id="search_btn" class="layui-btn layui-btn-normal"><i class="layui-icon"></i> 搜 索</button>
    </div>
</div>

<div style="margin-top: 20px;margin-left: 20px;margin-right: 20px">
    <table class="layui-show" id="dataTable" lay-filter="dataTable" style="width: 80%"></table>

</div>

<script type="text/html" id="method">
    {{#if (d.method == '0') { }}
    <span>Post</span>
    {{# }else if(d.method == '1'){ }}
    <span>Get</span>
    {{# }else if(d.method == '2'){ }}
    <span>Put</span>
    {{# }else if(d.method == '3'){ }}
    <span>Delete</span>
    {{# } }}
</script>

<script type="text/html" id="resulta">
    {{#if (d.result == "pass" ) { }}
    <span style="color:green;">PASS</span>
    {{# }else if(d.result == 'fail'){ }}
    <span style="color:orangered;">FAIL</span>
    {{# } }}
</script>

<script type="text/html" id="caseType">
    {{#if (d.caseType == "1" ) { }}
    <span >独立</span>
    {{# }else if(d.caseType == '2'){ }}
    <span >组合</span>
    {{# } }}
</script>

<script type="text/html" id="executeIdText">
    {{#if (d.executeId == "0" ) { }}
    <span ></span>
    {{# } }}
</script>



<script src="/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>
    layui.use(['element', 'table', 'layer'], function () {
        var $ = layui.jquery,
            element = layui.element,
            layer = layui.layer,
            form = layui.form,
            table = layui.table;

        $(function initFlowCase() {
            var Id = localStorage.flowResult==="null"?"":JSON.parse(localStorage.flowResult).taskId;
            $("#taskId").html("");
            $("#taskId").val(Id);
            localStorage.setItem("flowResult",null);
        })

        table.render({
            elem: "#dataTable",
            url: '/va/reportList'+'?labelName='+ $("#labelName").val()+"&tag="+$("#tag").val()+"&taskId="+$("#taskId").val(),
            cols: [
                [
                    {field: 'id', title: '序号', width: 80, sort: true}
                    , {field: 'taskId', title: '任务名称', width: 300}
                    , {field: 'caseType', title: '用例类型', width: 100,templet: "#caseType" }
                    , {field: 'labelName', title: '业务名称', width: 150}
                    , {field: 'executeId', title: '执行顺序', width: 100,templet: "#executeIdText"}
                    , {field: 'tag', title: '用例名称', width: 250}
                    , {field: 'method', title: '请求方式', width: 100, templet: "#method"}
                    , {field: 'url', title: '接口地址', width: 200}
                    , {field: 'result', title: '测试结果', width: 100, templet: "#resulta"}
                    , {field: 'params', title: '请求参数', width: 200}
                    , {field: 'testAccount', title: '测试账号', width: 150}
                    , {field: 'response', title: '响应结果', width: 200}
                    , {field: 'errorLog', title: '错误日志', width: 200}
                    , {field: 'testUser', title: '测试人员', width: 100}
                    , {field: 'testTime', title: '测试时间', width: 200, sort: true,templet : "<div>{{layui.util.toDateString(d.create_time, 'yyyy年MM月dd日 HH:mm:ss')}}</div>"}
                ]
            ]
            , page: true
            // ,skin:"line"
            , id: 'dataReload'
        });

        //点击搜索后，重新加载表格数据
        $('#search_btn').on("click", function () {
            table.reload("dataReload", {
                method:"get",
                url: '/va/reportList'+'?labelName='+ $("#labelName").val()+"&tag="+$("#tag").val()+"&taskId="+$("#taskId").val(),
                page:1
            })
        })

    });

</script>

</body>
</html>

